package com.mk.admin.controller;

import com.mk.admin.controller.BaseController;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.vo.PatAddressVo;
import com.mk.admin.service.PatAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/a/adm/patAddress")
@Api(tags = "患者地址")
public class PatAddressController extends BaseController<PatAddressVo> {
    @Autowired
    private PatAddressService patAddressService;

    @PostMapping("/select")
    @Override
    public ResultDto select(@RequestBody PatAddressVo patAddressVo) {
        return patAddressService.select(patAddressVo);
    }

    @PostMapping("/add")
    @ApiOperation(value = "增加地址", notes = "如果status设为默认1，则以前的状态会自动变为0")
    @Override
    public ResultDto add(@RequestBody PatAddressVo patAddressVo) {
        return patAddressService.add(patAddressVo);
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改地址", notes = "如果status设为默认1，则以前的状态会自动变为0")
    @Override
    public ResultDto update(@RequestBody PatAddressVo patAddressVo) {
        return patAddressService.update(patAddressVo);
    }

    @PostMapping("/delete")
    @Override
    public ResultDto delete(@RequestBody PatAddressVo patAddressVo) {
        return patAddressService.delete(patAddressVo.getId());
    }

    @PostMapping("/status")
    @ApiOperation(value = "状态 1为默认选择", notes = "单独修改默认地址状态")
    @Override
    public ResultDto status(@RequestBody PatAddressVo patAddressVo) {
        return patAddressService.status(patAddressVo.getId());
    }
}
